<html>
	<?php
		$code = $_POST['code'];
		$pnum = $_POST['pnum'];
		echo "<h1>$pnum</h1>";
		$exename = 'run';
		$handle = fopen("./pasfile/$exename.pas", 'w');
		fwrite($handle, $code);
		fclose($handle);
		passthru("./compile.sh ./pasfile/$exename.pas ./pasfile/$exename");
		$confName = "./pasfile/input/$pnum/$pnum".".conf";
		$handle = fopen($confName, "r");
		while ($probInfo = fscanf($handle, "%s %s\n")){
			list($inputfile, $outputfile) = $probInfo;
			$inputfilename = "./pasfile/input/$pnum/$inputfile";
			$outputfilename = "./pasfile/output/$pnum/$outputfile";
			$tmpoutputfilename = "./pasfile/output/tmpoutput/$exename"."out";
			passthru("./runshell.sh ./pasfile/$exename $inputfilename $outputfilename $tmpoutputfilename");
		}
		fclose($handle);
	?>
</html>
